﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Entity;

namespace DAO
{
    public class PermissionDAO
    {
        BMS_DatabaseEntities context = new BMS_DatabaseEntities();
        public PermissionEntity LoadPermission(string groupname)
        {
            PermissionEntity per = new PermissionEntity();

            var query = (from s in context.PERMISSION_INFO where s.GROUP_NAME == groupname select s).First();

            per.GroupName = query.GROUP_NAME;
            per.View = (bool)query.VIEW_INFO;
            per.Insert = (bool)query.INSERT_INFO;
            per.Delete = (bool)query.DELETE_INFO;
            per.Update = (bool)query.UPDATE_INFO;
            per.AllPermission = (bool)query.ALL_PERMISSION;

            return per;
        }
    }
}
